package com.java2_29;
//class MyThread extends Thread{
//    @Override
//    public void run() {
//        System.out.println("这是MyThread想要执行的语句");
//    }
//}
//使用继承的方式创建多线程
//class MyThread extends Thread{
//    @Override
//    public void run() {
//        System.out.println("这是重写的run方法");
//    }
//}//    public static void main(String[] args) {
////        MyThread myThread = new MyThread();
////        myThread.start();
////    }
////    public static void main(String[] args) {
////        MyThread myThread = new MyThread();
////        myThread.start();
////
////    }
//使用实现类来创建多线程
//class MyThread implements Runnable{
//    @Override
//    public void run() {
//        System.out.println("这是使用接口来创建多线程");
//    }
//}
//    public static void main(String[] args) {
////        MyThread myThread = new MyThread();
////        Thread thread = new Thread(myThread);
////        thread.start();
//    }
//class MyThread implements Runnable{
//    @Override
//    public void run() {
//        System.out.println("This is a test!");
//    }
//}
//        MyThread myThread = new MyThread();
//        Thread thread = new Thread(myThread);
//        thread.start();


public class java2_29 {
    //    public static void main(String[] args) {
//        //使用匿名内部类来创建多线程
////        Thread thread = new Thread() {
////            @Override
////            public void run() {
////                System.out.println("这是一个匿名内部类创建多线程的实现");
////            }
////        };
////        thread.start();
////        new Thread(){
////            @Override
////            public void run() {
////                System.out.println("这是另一个创建多线程的匿名内部类方式");
////            }
////        }.start();
//
//        //匿名实现类
////        new Thread(new Runnable() {
////            @Override
////            public void run() {
////                System.out.println("this is a test !");
////            }
////        }).start();
//
////        Thread thread = new Thread(new Runnable() {
////            @Override
////            public void run() {
////                System.out.println("this is a test !");
////            }
////        });
////        thread.start();
//
//
//    }
//    public static void main(String[] args) {
//        //两种方式推荐使用第二种
////        /**
////         * （1）突破了Java单继承的特点
////         * （2）数据的共享
////         * （3）实现了代码和数据的分离
////         * */
////        MyThread myThread = new MyThread();
////        Thread thread = new Thread(myThread,"线程1");
////        thread.start();
////        MyThreadJi myThreadJi = new MyThreadJi("线程1");
////        myThreadJi.start();
//
////        MyThreadJi myThreadJi1 = new MyThreadJi("线程1");
////        MyThreadJi myThreadJi2 = new MyThreadJi("线程2");
////        MyThreadJi myThreadJi3 = new MyThreadJi("线程3");
////
////        myThreadJi1.start();
////        myThreadJi2.start();
////        myThreadJi3.start();
////
////        System.out.println(MyThreadJi.getNumber());
//
//    }
//    public static void main(String[] args) {
//        MyThread myThread = new MyThread();
//        Thread thread1 = new Thread(myThread);
//        Thread thread2 = new Thread(myThread);
//        Thread thread3 = new Thread(myThread);
//
//        thread1.start();
//        thread2.start();
//        thread3.start();
//
//        System.out.println(myThread.getNumber());
//
//    }
//    public static void main(String[] args) {
//        System.out.println(Thread.currentThread().getName());
//        //currentThread() -- 获取当前的线程名字
//
//        //start() -- 1.开始线程  2.启用run（）方法
//        //run（）方法 -- 就是线程所要干的事情
//
////        MyThreadJi myThreadJi = new MyThreadJi();
////        myThreadJi.setName("线程0");
////        myThreadJi.start();
//
//        //由于这些方法都是存在与Thread大类中的，所以其子类可以直接使用
//
////        MyThreadJi myThreadJi = new MyThreadJi();
////        System.out.println(myThreadJi.getPriority());
////        myThreadJi.start();
//
////        MyThread myThread = new MyThread();
////        Thread thread = new Thread(myThread);
////        thread.setPriority(10);
//
//    }
    public static void main(String[] args) {
        MyThreadJi myThreadJi1 = new MyThreadJi("线程1");
        MyThreadJi myThreadJi2 = new MyThreadJi("线程2");

        //设置线程的优先级
        myThreadJi1.setPriority(Thread.MAX_PRIORITY);
        myThreadJi2.setPriority(Thread.MIN_PRIORITY);
        myThreadJi2.start();
        myThreadJi1.start();


    }


}
